/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: WHY
 * Date: 2022-10-17
 * Time: 20:05
 */
//给定一个字符串A和它的长度n,清返回一个布尔值，判断该字符串是否为合法字符串
public class   boolean chkParenthesis(String A,int n) {
    if(n%2!=0){
        return false;
    }
   Stack<Character> stack=new Stack();//创建一个栈
    for(char c:A.toCharArray()){//字符串转数组,并且遍历
        if(c=='('){//如果是左括号，那么入栈
            stack.push(c);
        }else if(c==")"){//如果是右括号，先判断栈是否为空
            if(stack.isEmpyt()){
                return false
        }else if(){
                stack.peek();
                if(stack.peek()=="("){
                    stack.pop()
        }
        }else{
                return false;
        }
        }
        return (stack.isEmpty);//最后在判断是否为空，返回Boolean值
        }

}
